package com.mxtech.agilenav.foundation;

public class Commu {
	
	private static final String base_url = "xxxx";

	public void UserRegister(InParamUsrReg inPpara, AsyncResponse resp) {
		// full url is "http://110.191.191.11:8080/agilenav/usr/
		String url_str = base_url + "usr/";
		Object res_value;
		try {
			JSONObject reqobj = new JSONObject();
			reqobj.put("name", inPpara.name);
			reqobj.put("password", inPpara.password);
			StringEntity stringEntity = new StringEntity(reqobj.toString());
			client.put(null, url_str, stringEntity, "application/json",
					new JsonHttpResponseHandler() {
						@Override
						public void onSuccess(JSONObject result) {
							try {
								String tmp_str = result.getString("errcode");
								res_value = Integer.parseInt(tmp_str);
								resp.onSuccess(OutParamUsrReg);
							} catch (JSONException ex) {
								res_value = ErrCode.FAILURE;
								resp.onError(res_value);								
							}
						}
					});
		} catch (JSONException ex) {
			res_value = ErrCode.FAILURE;
			resp.onError(res_value);	
		} catch (UnsupportedEncodingException ex) {
			res_value = ErrCode.FAILURE;
			resp.onError(res_value);	
		}		
	}
}
